<div id="spec_tab">
<script type="text/javascript" src="${ctx}/shop/admin/js/spec/memberprice.js"></script>
<script type="text/javascript" src="${ctx}/shop/admin/js/spec/spec-v2.js"></script>

<style>
.select-spec-value {
	background: none repeat scroll 0 0 #FFFFFF;
	border: 2px solid #FFFFFF;
	display: block;
}

div.spec_selected {
	width: 50px
}

.select-spec-unselect span,.select-spec-unselect img {
	background: none repeat scroll 0 0 #FFFFFF;
	border: 1px dotted #3366CC;
	color: #333333;
	cursor: pointer;
	display: block;
	padding: 1px;
	font-size: 14px;
	text-align: center;
	line-height: 150%;
}

.spec_selected span,.spec_selected img {
	background: none repeat scroll 0 0 #FFFFCC;
	border-style: solid;
}

table.finderInform {
border:1px solid #EFEFEF;
margin:0;
width:100%;
}
.division td .finderInform {
width:auto;
}
.finderInform thead th {

border-color:#FFFFFF #DBE2E7 #CCCCCC #FFFFFF;
border-style:solid;
border-width:1px;
font-size:12px;
font-weight:700;
padding:1px 3px;
text-align:center;
white-space:nowrap;
width:auto;
}
.finderInform td {
text-align:center;
}
.finderInform tbody td, .finderInform tbody th {
border-color:#FFFFFF #DBE2E7 #DDDDDD #FFFFFF;
border-left:1px solid #FFFFFF;
border-right:1px solid #DBE2E7;
border-style:solid;
border-width:1px;
}
.finderInform tbody td {
white-space:normal;
}
.finderInform.tabledata th, .finderInform.tabledata td {
text-align:left;
}
</style>

<input type="hidden" name="haveSpec" id="haveSpec" value="${goods.have_spec!0}" />

<table id="body1" class="form-table">
	<tbody>
 
		<tr>
			<th>销售价：</th>
			<td><input type="text" maxlength="25" style="width: 60px;"
				name="price" id="price" class="price input_text" autocomplete="off"  dataType=float value="${(goods.price!0)?c}">
				<input type="button" class="mempriceBtn" value="编辑会员价格" class="button "/>
				<div class="member_price_box" ><!-- 声明控件，稍后初始化 -->
				<#if lvList?exists>
				<#list lvList as lv>
					<input type="hidden" class="lvid"  value="${lv.lv_id}" name="lvid">
					<input type="hidden" class="lvPrice" lvid="${lv.lv_id}" name="lvPrice">
				</#list>
				</#if>
			</div>
			&nbsp;&nbsp;<span class="help_icon" helpid="goods_price"></span>
			</td>
		</tr>
		<tr>
			<th>成本价：</th>
			<td><input type="text" style="width: 60px;" maxlength="30"
				name="cost" id="cost" autocomplete="off" value="${(goods.cost!0)?c}" class="input_text"> 
			&nbsp;&nbsp;<span class="help_icon" helpid="goods_cost"></span>
			</td>
		</tr>

		<tr>
			<th>重量：</th>
			<td><input type="text" maxlength="25" style="width: 60px;"
				name="weight" id="weight" autocomplete="off" value="${(goods.weight!0)?c}" class="input_text">克(g)</td>
		</tr>


		<tr class="advui">
			<th>规格：</th>
			<td style="padding: 4px 0pt;">
			<input type="button" id="specOpenBtn" value="开启规格" class="button" />
			&nbsp;&nbsp;<span class="help_icon" helpid="goods_spec"></span>
			</td>
		</tr>
	</tbody>
</table>



<div class="grid" id="body2">
<input type="button" id="specCloseBtn" value="关闭规格" goodsid="${goods.goods_id!'0'}" class="button "/>
<table cellspacing="0" cellpadding="0" border="0">
	<thead id="productNodeTitle">
		<tr>
			<th style="width: 200px;">货号</th>
			<#if goods.have_spec?exists && goods.have_spec==1 && specNameList?exists  >
			<#list specNameList as specName>
			<th style="width: auto">${specName}</th>
			</#list>
			</#if>
			<th style="width: auto;" id="priceTh">销售价</th>
			<th style="width: auto;">成本价</th>
			<th style="width: auto;">重量</th>
			<th style="width: auto;">操作</th>
		</tr>

	</thead>
	<tbody id="productNode">
	
		<#if goods.have_spec?exists && goods.have_spec==1 && productList?exists  >
		<#list productList as product>
		<#assign specids=''>
		<#assign specvids=''>
		
		
		<tr>
			<td>
			<input type="text" style="width:150px" name="sns" value="${product.sn}" autocomplete="off">
			<input type="hidden" name="productids" value="${product.product_id}" />
			</td>
			
			<#list product.specList as spec>
				 

				<#if spec_index!=0 >
					<#assign specids=specids+','>
					<#assign specvids=specvids+','>
				</#if>
				<#assign specids=specids+spec.spec_id>
				<#assign specvids=specvids+spec.spec_value_id>		
						
				<#if spec.spec_type==1>
				<td>
				<div class="select-spec-unselect spec_selected">
				<center><img height="20" width="20" src="${spec.spec_image}"
					alt="${spec.spec_value}" title="${spec.spec_value}"></center>
				</div>
				<input type="hidden" name="specvalue_${product_index}" value="${spec.spec_value}" />
				</td>
				</#if>
				
				<#if spec.spec_type==0>
				<td>
				<div class="select-spec-unselect spec_selected"><span>${spec.spec_value}</span></div>
				<input type="hidden" name="specvalue_${product_index}" value="${spec.spec_value}" />
				</td>
				</#if>
				
 			</#list>
			
	 
				
			<td>
				<input type="hidden" value="${specids}" name="specids">
				<input type="hidden" value="${specvids}" name="specvids">
			<input type="text" size="8" name="prices" class="price" value="${(product.price!0)?c}" autocomplete="off"> <!-- <input type="button" class="mempriceBtn" value="会员价" /> -->
					<div class="member_price_box" index="${product_index}"><!-- 声明控件，稍后初始化 -->
				<#if lvList?exists>
				<#list lvList as lv>
				<input type="hidden" class="lvid" productid="${product.product_id}" value="${lv.lv_id}" name="lvid_${product_index}">
				<input type="hidden" class="lvPrice"  productid="${product.product_id}" lvid="${lv.lv_id}" name="lvPrice_${product_index}">
				</#list>
				</#if>
			</div></td>
			<td><input type="text" size="8" name="costs" value="${(product.cost!0)?c}" autocomplete="off"></td>
			<td><input type="text" size="10" name="weights" value="${(product.weight!0)?c}" autocomplete="off"></td>
			<td><a  href="javascript:;"><img  class="delete" src="${ctx}/shop/admin/images/transparent.gif" productid="${product.product_id}"> </a></td>
		</tr>
		</#list>
		<script>
		$(function(){
			//初始化货品会员价
			$.ajax({
				url:'${ctx}/shop/admin/member-price/get-lv-price-json.do?ajax=yes',
				data:'goodsid=${goods.goods_id}',
				dataType:'json',
				success:function(result){
					if(result.result==1){
						var priceData = result.priceData;
						$.each(priceData,function(i,price){
							$(".member_price_box>input.lvPrice[productid="+price.productid+"][lvid="+price.lvid+"]").val(price.price);
						});
					}
					else{
						alert("生成会员价格出错："+result.message);
					}
				},
				error:function(){
					alert("生成会员价格出错");
				}
			});

			MemberPrice.bindMbPricBtnEvent();
		})
		</script>
		
		<#else>
			<#if goods.goods_id?exists >
			<script>
			$(function(){
				//初始化商品会员价
				$.ajax({
					url:'${ctx}/shop/admin/member-price/get-lv-price-json.do',
					data:'goodsid=${goods.goods_id}',
					dataType:'json',
					success:function(result){
						if(result.result==1){
							var priceData = result.priceData;
							$.each(priceData,function(i,price){
								$(".member_price_box>input.lvPrice[lvid="+price.lvid+"]").val(price.price);
							});
						}
						else{
							alert("生成会员价格出错："+result.message);
						}
					},
					error:function(){
						alert("生成会员价格出错");
					}
				});
	
				MemberPrice.bindMbPricBtnEvent();
			})
			</script>		
			</#if>	
		</#if>
	</tbody>
</table>
<input type="hidden" name="spec_imgs" id="spec_imgs" /></div>

<div id="specdlg">
<div id="spec_dialog"></div>
<div class="footContent" style="">
<div style="width: 200px; height: 40px; margin: 0pt auto;"
	class="mainFoot">
<table style="margin: 0pt auto; width: auto;">
	<tbody>
		<tr>
			<td><b class="save_create">
			<button class="submitBtn">生成所有货品</button>
			</b></td>

		</tr>
	</tbody>
</table>
</div>
</div>
</div>

 
</div>